import * as type from 'common/src/store/mutation-type'
import {
  requireTaskByStudent,
  getOneTask
} from 'common/src/api/welcomeService/taskTemplate'

const taskTemplate = {
  state: {
    tasks: []
  },
  getters: {

  },
  actions: {
    async getStudentTasks({
      commit,
      state
    }, query) {
      let firstMenu = {
        templateId: ''
      },
      status = '';
      let res = await requireTaskByStudent(query)
      if (res.data && res.data.length > 0) {
        // res.data.map((item, index) => {
        //   if (index === 0) {
        //     firstMenu.templateId = item.templateId;
        //     status = item.status;
        //     item.isActive = true;
        //   } else {
        //     item.isActive = false;
        //   }
        // });
        commit(type.TASK_LIST, res.data)
      }
      // let task = await getOneTask(firstMenu);
      // task.data.taskStatus = status;
      // commit(type.TASK_LIST, {
      //     taskList: res.data,
      //     currentTask: task.data
      // })
    }
  },
  mutations: {
    //获取用户信息存入vuex
    [type.TASK_LIST](state, info) {
      state.tasks = info
    },
  }
};

export default taskTemplate
